home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume11 / musbus / part03 < prev    next >
Encoding:
Text File  |  1987-09-16  |  51.5 KB  |  1,972 lines

  1. Path: uunet!munnari!sources-request
  2. From: sources-request@munnari.oz
  3. Newsgroups: comp.sources.unix
  4. Subject: v11i031:  MUSBUS 5.0 -- Monash University Benchmark, Part03/04
  5. Message-ID: <1827@munnari.oz>
  6. Date: 17 Sep 87 08:18:22 GMT
  7. Sender: kre@munnari.oz
  8. Lines: 1961
  9. Approved: kre@munnari.oz.au
  10.  
  11. Submitted by: kenj@moncsbruce.oz.au (Ken McDonell)
  12. Posting-number: Volume 11, Issue 31
  13. Archive-name: musbus/Part03
  14.  
  15. #! /bin/sh
  16. # This is a shell archive, meaning:
  17. # 1. Remove everything above the #! /bin/sh line.
  18. # 2. Save the resulting text in a file.
  19. # 3. Execute the file with /bin/sh (not csh) to create the files:
  20. #    grep.dat
  21. #    hanoi.c
  22. #    iamalive.c
  23. #    keyb.c
  24. #    limit.c
  25. #    log.785
  26. #    log.sun3-50
  27. #    log.uVaxII
  28. #    makework.c
  29. #    makework.h
  30. #    mem.awk
  31. # This archive created: Thu Sep 17 06:48:15 EST 1987
  32. export PATH; PATH=/bin:$PATH
  33. echo 'x - grep.dat'
  34. if test -f 'grep.dat'
  35. then
  36.     echo 'shar: over-writing existing file grep.dat'
  37. fi
  38. sed 's/^X//' > grep.dat <<'End-of-File-Grunt'
  39. X/*
  40. X *  makework  -- emulate a series of terminal users
  41. X *
  42. X *  makework [ -r rate ] [ -c copyfile ] nusers
  43. X *
  44. X *  job streams are specified on standard input with lines of the form
  45. X *  full_path_name_for_command [ options ] [ <standard_input_file ]
  46. X *
  47. X *  "standard input" is send to all nuser instances of the commands in the
  48. X *  job streams at a rate not in excess of "rate" characters per second
  49. X *  per command
  50. X *
  51. X *  $Header: grep.dat,v 1.1 87/06/17 16:23:56 kjmcdonell Beta $
  52. X */
  53. X
  54. X#include <stdio.h>
  55. X#include <signal.h>
  56. X
  57. X#define DEF_RATE    5.0
  58. X#define GRANULE        5
  59. X#define CHUNK        60
  60. X#define MAXCHILD    12
  61. X#define MAXWORK        10
  62. X
  63. Xfloat    thres;
  64. Xfloat    est_rate = DEF_RATE;
  65. Xint    nusers;        /* number of concurrent users to be simulated by
  66. X             * this process */
  67. Xint    firstuser;    /* ordinal identification of first user for this
  68. X             * process */
  69. Xint    nwork = 0;    /* number of job streams */
  70. Xint    exit_status = 0;    /* returned to parent */
  71. Xint    sigpipe;    /* pipe write error flag */
  72. X
  73. Xstruct st_work {
  74. X    char    *cmd;        /* name of command to run */
  75. X    char    **av;        /* arguments to command */
  76. X    char    *input;        /* standard input buffer */
  77. X    int    inpsize;    /* size of standard input buffer */
  78. X    char    *outf;        /* standard output (filename) */
  79. X} work[MAXWORK];
  80. X
  81. Xstruct {
  82. X    int    xmit;    /* # characters sent */
  83. X    char    *bp;    /* std input buffer pointer */
  84. X    int    blen;    /* std input buffer length */
  85. X    int    fd;    /* stdin to command */
  86. X    int    pid;    /* child PID */
  87. X    char    *line;    /* start of input line */ 
  88. X    int    firstjob;    /* inital piece of work */
  89. X    int    thisjob;    /* current piece of work */
  90. X} child[MAXCHILD], *cp;
  91. X
  92. Xmain(argc, argv)
  93. Xint    argc;
  94. Xchar    *argv[];
  95. X{
  96. X    int        i;
  97. X    int        l;
  98. X    int        fcopy = 0;    /* fd for copy output */
  99. X    int        master = 1;    /* the REAL master, == 0 for clones */
  100. X    int        nchild;        /* no. of children for a clone to run */
  101. X    int        done;        /* count of children finished */
  102. X    int        output;        /* aggregate output char count for all
  103. X                   children */
  104. X    int        c;
  105. X    int        thiswork = 0;    /* next job stream to allocate */
  106. X    int        nch;        /* # characters to write */
  107. X    int        written;    /* # characters actully written */
  108. X    char    logname[15];    /* name of the log file(s) */
  109. X    int        onalarm();
  110. X    int        pipeerr();
  111. X    int        wrapup();
  112. X    int        grunt();
  113. X    int        pvec[2];    /* for pipes */
  114. X    char    *p;
  115. X    char    *prog;        /* my name */
  116. X
  117. X#if ! debug
  118. X    freopen("masterlog.00", "a", stderr);
  119. X#endif
  120. X    fprintf(stderr, "*** New Run ***  ");
  121. X    prog = argv[0];
  122. X    while (argc > 1 && argv[1][0] == '-')  {
  123. X    p = &argv[1][1];
  124. X    argc--;
  125. X    argv++;
  126. X    while (*p) {
  127. X        switch (*p) {
  128. X        case 'r':
  129. X            est_rate = atoi(argv[1]);
  130. X            sscanf(argv[1], "%f", &est_rate);
  131. X            if (est_rate <= 0) {
  132. X                fprintf(stderr, "%s: bad rate, reset to %.2f chars/sec\n", prog, DEF_RATE);
  133. X                est_rate = DEF_RATE;
  134. X            }
  135. X            argc--;
  136. X            argv++;
  137. X            break;
  138. X
  139. X        case 'c':
  140. X            fcopy = open(argv[1], 1);
  141. X            if (fcopy < 0)
  142. X                fcopy = creat(argv[1], 0600);
  143. X            if (fcopy < 0) {
  144. X                fprintf(stderr, "%s: cannot open copy file '%s'\n",
  145. X                prog, argv[1]);
  146. X                exit(2);
  147. X            }
  148. X            lseek(fcopy, 0L, 2);    /* append at end of file */
  149. X            argc--;
  150. X            argv++;
  151. X            break;
  152. X
  153. X        default:
  154. X        fprintf(stderr, "%s: bad flag '%c'\n", prog, *p);
  155. X            exit(4);
  156. X        }
  157. X        p++;
  158. X    }
  159. X    }
  160. X    
  161. X    if (argc < 2) {
  162. X    fprintf(stderr, "%s: missing nusers\n", prog);
  163. X    exit(4);
  164. X    }
  165. X
  166. X    nusers = atoi(argv[1]);
  167. X    if (nusers < 1) {
  168. X    fprintf(stderr, "%s: impossible nusers (%d<-%s)\n", prog, nusers, argv[1]);
  169. X    exit(4);
  170. X    }
  171. X    fprintf(stderr, "%d Users\n", nusers);
  172. X    argc--;
  173. X    argv++;
  174. X
  175. X    /* build job streams */
  176. X    getwork();
  177. X#if debug
  178. X    dumpwork();
  179. X#endif
  180. X
  181. X    /* clone copies of myself to run up to MAXCHILD jobs each */
  182. X    firstuser = MAXCHILD;
  183. X    fprintf(stderr, "master pid %d\n", getpid());
  184. X    fflush(stderr);
  185. X    while (nusers > MAXCHILD) {
  186. X    fflush(stderr);
  187. X    if (nusers >= 2*MAXCHILD)
  188. X        /* the next clone must run MAXCHILD jobs */
  189. X        nchild = MAXCHILD;
  190. X    else
  191. X        /* the next clone must run the leftover jobs */
  192. X        nchild = nusers - MAXCHILD;
  193. X    if ((l = fork()) == -1) {
  194. X        /* fork failed */
  195. X        fatal("** clone fork failed **\n");
  196. X        goto bepatient;
  197. X    } else if (l > 0) {
  198. X        fprintf(stderr, "master clone pid %d\n", l);
  199. X        /* I am the master with nchild fewer jobs to run */
  200. X        nusers -= nchild;
  201. X        firstuser += MAXCHILD;
  202. X        continue;
  203. X    } else {
  204. X        /* I am a clone, run MAXCHILD jobs */
  205. X#if ! debug
  206. X        sprintf(logname, "masterlog.%02d", firstuser/MAXCHILD);
  207. X        freopen(logname, "w", stderr);
  208. X#endif
  209. X        master = 0;
  210. X        nusers = nchild;
  211. X        break;
  212. X    }
  213. X    }
  214. X    if (master)
  215. X    firstuser = 0;
  216. X
  217. X    close(0);
  218. X    for (i = 0; i < nusers; i++ ) {
  219. X    fprintf(stderr, "user %d job %d ", firstuser+i, thiswork);
  220. X    if (pipe(pvec) == -1) {
  221. X        /* this is fatal */
  222. X        fatal("** pipe failed **\n");
  223. X        goto bepatient;
  224. X    }
  225. X    fflush(stderr);
  226. X    if ((child[i].pid = fork()) == 0) {
  227. X        int    fd;
  228. X        /* the command */
  229. X        if (pvec[0] != 0) {
  230. X        close(0);
  231. X        dup(pvec[0]);
  232. X        }
  233. X#if ! debug
  234. X        sprintf(logname, "userlog.%02d", firstuser+i);
  235. X        freopen(logname, "w", stderr);
  236. X#endif
  237. X        for (fd = 3; fd < 24; fd++)
  238. X        close(fd);
  239. X        if (work[thiswork].outf[0] != '\0') {
  240. X        /* redirect std output */
  241. X        char    *q;
  242. X        for (q = work[thiswork].outf; *q != '\n'; q++) ;
  243. X        *q = '\0';
  244. X        if (freopen(work[thiswork].outf, "w", stdout) == NULL) {
  245. X            fprintf(stderr, "makework: cannot open %s for std output\n",
  246. X            work[thiswork].outf);
  247. X            fflush(stderr);
  248. X        }
  249. X        *q = '\n';
  250. X        }
  251. X        execv(work[thiswork].cmd, work[thiswork].av);
  252. X        /* don't expect to get here! */
  253. X        fatal("** exec failed **\n");
  254. X        goto bepatient;
  255. X    }
  256. X    else if (child[i].pid == -1) {
  257. X        fatal("** fork failed **\n");
  258. X        goto bepatient;
  259. X    }
  260. X    else {
  261. X        close(pvec[0]);
  262. X        child[i].fd = pvec[1];
  263. X        child[i].line = child[i].bp = work[thiswork].input;
  264. X        child[i].blen = work[thiswork].inpsize;
  265. X        child[i].thisjob = thiswork;
  266. X        child[i].firstjob = thiswork;
  267. X        fprintf(stderr, "pid %d pipe fd %d", child[i].pid, child[i].fd);
  268. X        if (work[thiswork].outf[0] != '\0') {
  269. X        char *q;
  270. X        fprintf(stderr, " > ");
  271. X        for (q=work[thiswork].outf; *q != '\n'; q++)
  272. X            fputc(*q, stderr);
  273. X        }
  274. X        fputc('\n', stderr);
  275. X        thiswork++;
  276. X        if (thiswork >= nwork)
  277. X        thiswork = 0;
  278. X    }
  279. X    }
  280. X    fflush(stderr);
  281. X
  282. X    srand(time(0));
  283. X    thres = 0;
  284. X    done = output = 0;
  285. X    for (i = 0; i < nusers; i++) {
  286. X    if (child[i].blen == 0)
  287. X        done++;
  288. X    else
  289. X        thres += est_rate * GRANULE;
  290. X    }
  291. X    est_rate = thres;
  292. X
  293. X    signal(SIGALRM, onalarm);
  294. X    signal(SIGPIPE, pipeerr);
  295. X    alarm(GRANULE);
  296. X    while (done < nusers) {
  297. X    for (i = 0; i < nusers; i++) {
  298. X        cp = &child[i];
  299. X        if (cp->xmit >= cp->blen) continue;
  300. X        l = rand() % CHUNK + 1;    /* 1-CHUNK chars */
  301. X        if (l == 0) continue;
  302. X        if (cp->xmit + l > cp->blen)
  303. X        l = cp->blen - cp->xmit;
  304. X        p = cp->bp;
  305. X        cp->bp += l;
  306. X        cp->xmit += l;
  307. X#if debug
  308. X        fprintf(stderr, "child %d, %d processed, %d to go\n", i, cp->xmit, cp->blen - cp->xmit);
  309. X#endif
  310. X        while (p < cp->bp) {
  311. X        if (*p == '\n' || (p == &cp->bp[-1] && cp->xmit >= cp->blen)) {
  312. X            /* write it out */
  313. X            nch = p - cp->line + 1;
  314. X            if ((written = write(cp->fd, cp->line, nch)) != nch) {
  315. X            /* argh! */
  316. X            cp->line[nch] = '\0';
  317. X            fprintf(stderr, "user %d job %d cmd %s ",
  318. X                firstuser+i, cp->thisjob, cp->line);
  319. X             fprintf(stderr, "write(,,%d) returns %d\n", nch, written);
  320. X            if (sigpipe)
  321. X                fatal("** SIGPIPE error **\n");
  322. X            else
  323. X                fatal("** write error **\n");
  324. X            goto bepatient;
  325. X
  326. X            }
  327. X            if (fcopy)
  328. X            write(fcopy, cp->line, p - cp->line + 1);
  329. X#if debug
  330. X            fprintf(stderr, "child %d gets \"", i);
  331. X            {
  332. X            char *q = cp->line;
  333. X            while (q <= p) {
  334. X                if (*q >= ' ' && *q <= '~')
  335. X                    fputc(*q, stderr);
  336. X                else
  337. X                    fprintf(stderr, "\\%03o", *q);
  338. X                q++;
  339. X            }
  340. X            }
  341. X            fputc('"', stderr);
  342. X#endif
  343. X            cp->line = &p[1];
  344. X        }
  345. X        p++;
  346. X        }
  347. X        if (cp->xmit >= cp->blen) {
  348. X        done++;
  349. X        close(cp->fd);
  350. X#if debug
  351. X    fprintf(stderr, "child %d, close std input\n", i);
  352. X#endif
  353. X        }
  354. X        output += l;
  355. X    }
  356. X    while (output > thres) {
  357. X        pause();
  358. X#if debug
  359. X        fprintf(stderr, "after pause: output, thres, done %d %.2f %d\n", output, thres, done);
  360. X#endif
  361. X    }
  362. X    }
  363. X
  364. Xbepatient:
  365. X    alarm(0);
  366. X/****
  367. X *  If everything is going OK, we should simply be able to keep
  368. X *  looping unitil 'wait' fails, however some descendent process may
  369. X *  be in a state from which it can never exit, and so a timeout
  370. X *  is used.
  371. X *  5 minutes should be ample, since the time to run all jobs is of
  372. X *  the order of 5-10 minutes, however some machines are painfully slow,
  373. X *  so the timeout has been set at 20 minutes (1200 seconds).
  374. X ****/
  375. X    signal(SIGALRM, grunt);
  376. X    alarm(1200);
  377. X    while ((c = wait(&l)) != -1) {
  378. X        for (i = 0; i < nusers; i++) {
  379. X        if (c == child[i].pid) {
  380. X        fprintf(stderr, "user %d job %d pid %d done", firstuser+i, child[i].thisjob, c);
  381. X        if (l != 0) {
  382. X            if (l & 0x7f)
  383. X            fprintf(stderr, " status %d", l & 0x7f);
  384. X            if (l & 0xff00)
  385. X            fprintf(stderr, " exit code %d", (l>>8) & 0xff);
  386. X            exit_status = 4;
  387. X        }
  388. X        fputc('\n', stderr);
  389. X        c = child[i].pid = -1;
  390. X        break;
  391. X        }
  392. X    }
  393. X    if (c != -1) {
  394. X        fprintf(stderr, "master clone done, pid %d ", c);
  395. X        if (l != 0) {
  396. X        if (l & 0x7f)
  397. X            fprintf(stderr, " status %d", l & 0x7f);
  398. X        if (l & 0xff00)
  399. X            fprintf(stderr, " exit code %d", (l>>8) & 0xff);
  400. X        exit_status = 4;
  401. X        }
  402. X        fputc('\n', stderr);
  403. X    }
  404. X    }
  405. X    alarm(0);
  406. X    wrapup("Finished waiting ...");
  407. X
  408. X
  409. X}
  410. X
  411. Xonalarm()
  412. X{
  413. X    thres += est_rate;
  414. X    signal(SIGALRM, onalarm);
  415. X    alarm(GRANULE);
  416. X}
  417. X
  418. Xgrunt()
  419. X{
  420. X    /* timeout after label "bepatient" in main */
  421. X    exit_status = 4;
  422. X    wrapup("Timed out waiting for jobs to finish ...");
  423. X}
  424. X
  425. Xpipeerr()
  426. X{
  427. X    sigpipe++;
  428. X}
  429. X
  430. Xwrapup(reason)
  431. Xchar    *reason;
  432. X{
  433. X    int i;
  434. X    int killed = 0;
  435. X    fflush(stderr);
  436. X    for (i = 0; i < nusers; i++) {
  437. X    if (child[i].pid > 0 && kill(child[i].pid, SIGKILL) != -1) {
  438. X        if (!killed) {
  439. X        killed++;
  440. X        fprintf(stderr, "%s\n", reason);
  441. X        fflush(stderr);
  442. X        }
  443. X        fprintf(stderr, "user %d job %d pid %d killed off\n", firstuser+i, child[i].thisjob, child[i].pid);
  444. X    fflush(stderr);
  445. X    }
  446. X    }
  447. X    exit(exit_status);
  448. X}
  449. X
  450. Xgetwork()
  451. X{
  452. X    int            i;
  453. X    int            f;
  454. X    int            ac;
  455. X    char        *lp;
  456. X    char        *q;
  457. X    struct st_work    *w;
  458. X    char        line[512];
  459. X    char        c;
  460. X    char        *malloc(), *realloc();
  461. X
  462. X    while (gets(line) != NULL) {
  463. X    if (nwork >= MAXWORK) {
  464. X        fprintf(stderr, stderr, "Too many jobs specified, .. increase MAXWORK\n");
  465. X        exit(4);
  466. X    }
  467. X    w = &work[nwork];
  468. X    lp = line;
  469. X    i = 1;
  470. X    while (*lp && *lp != ' ') {
  471. X        i++;
  472. X        lp++;
  473. X    }
  474. X    w->cmd = (char *)malloc(i);
  475. X    strncpy(w->cmd, line, i-1);
  476. X    w->cmd[i-1] = '\0';
  477. X    w->inpsize = 0;
  478. X    w->input = "";
  479. X    /* start to build arg list */
  480. X    ac = 2;
  481. X    w->av = (char **)malloc(2*sizeof(char *));
  482. X    q = w->cmd;
  483. X    while (*q) q++;
  484. X    q--;
  485. X    while (q >= w->cmd) {
  486. X        if (*q == '/') {
  487. X        q++;
  488. X        break;
  489. X        }
  490. X        q--;
  491. X    }
  492. X    w->av[0] = q;
  493. X    while (*lp) {
  494. X        if (*lp == ' ') {
  495. X        /* space */
  496. X        lp++;
  497. X        continue;
  498. X        }
  499. X        else if (*lp == '<') {
  500. X        /* standard input for this job */
  501. X        q = ++lp;
  502. X        while (*lp && *lp != ' ') lp++;
  503. X        c = *lp;
  504. X        *lp = '\0';
  505. X        if ((f = open(q, 0)) == -1) {
  506. X            fprintf(stderr, "cannot open input file (%s) for job %d\n",
  507. X                q, nwork);
  508. X            exit(4);
  509. X        }
  510. X        /* gobble input */
  511. X        w->input = (char *)malloc(512);
  512. X        while ((i = read(f, &w->input[w->inpsize], 512)) > 0) {
  513. X            w->inpsize += i;
  514. X            w->input = (char *)realloc(w->input, w->inpsize+512);
  515. X        }
  516. X        w->input = (char *)realloc(w->input, w->inpsize);
  517. X        close(f);
  518. X        /* extract stdout file name from line beginning "C=" */
  519. X        w->outf = "";
  520. X        for (q = w->input; q < &w->input[w->inpsize-10]; q++) {
  521. X            if (*q == '\n' && strncmp(&q[1], "C=", 2) == 0) {
  522. X            w->outf = &q[3];
  523. X            break;
  524. X            }
  525. X        }
  526. X#if debug
  527. X        if (*w->outf) {
  528. X            fprintf(stderr, "stdout->");
  529. X            for (q=w->outf; *q != '\n'; q++)
  530. X            fputc(*q, stderr);
  531. X            fputc('\n', stderr);
  532. X        }
  533. X#endif
  534. X        }
  535. X        else {
  536. X        /* a command option */
  537. X        ac++;
  538. X        w->av = (char **)realloc(w->av, ac*sizeof(char *));
  539. X        q = lp;
  540. X        i = 1;
  541. X        while (*lp && *lp != ' ') {
  542. X            lp++;
  543. X            i++;
  544. X        }
  545. X        w->av[ac-2] = (char *)malloc(i);
  546. X        strncpy(w->av[ac-2], q, i-1);
  547. X        w->av[ac-2][i-1] = '\0';
  548. X        }
  549. X    }
  550. X    w->av[ac-1] = (char *)0;
  551. X    nwork++;
  552. X    }
  553. X}
  554. X
  555. X#if debug
  556. Xdumpwork()
  557. X{
  558. X    int        i;
  559. X    int        j;
  560. X
  561. X    for (i = 0; i < nwork; i++) {
  562. X    fprintf(stderr, "job %d: cmd: %s\n", i, work[i].cmd);
  563. X    j = 0;
  564. X    while (work[i].av[j]) {
  565. X        fprintf(stderr, "argv[%d]: %s\n", j, work[i].av[j]);
  566. X        j++;
  567. X    }
  568. X    fprintf(stderr, "input: %d chars text: ", work[i].inpsize);
  569. X    if (work[i].input == (char *)0)
  570. X        fprintf(stderr, "<NULL>\n");
  571. X    else {
  572. X            register char    *pend;
  573. X            char        *p;
  574. X        char        c;
  575. X        p = work[i].input;
  576. X        while (*p) {
  577. X            pend = p;
  578. X            while (*pend && *pend != '\n')
  579. X                pend++;
  580. X            c = *pend;
  581. X            *pend = '\0';
  582. X            fprintf(stderr, "%s\n", p);
  583. X            *pend = c;
  584. X            p = &pend[1];
  585. X        }
  586. X    }
  587. X    }
  588. X}
  589. X#endif
  590. X
  591. Xfatal(s)
  592. Xchar *s;
  593. X{
  594. X    int    i;
  595. X    fprintf(stderr, s);
  596. X    fflush(stderr);
  597. X    perror("Reason?");
  598. X    fflush(stderr);
  599. X    for (i = 0; i < nusers; i++) {
  600. X    if (child[i].pid > 0 && kill(child[i].pid, SIGKILL) != -1) {
  601. X        fprintf(stderr, "pid %d killed off\n", child[i].pid);
  602. X        fflush(stderr);
  603. X    }
  604. X    }
  605. X    exit_status = 4;
  606. X    return;
  607. X}
  608. End-of-File-Grunt
  609. if test 13130 -ne `cat 'grep.dat' | wc -c`
  610. then
  611.     echo 'shar: transmission error (expected 13130 characters)'
  612. fi
  613. echo 'x - hanoi.c'
  614. if test -f 'hanoi.c'
  615. then
  616.     echo 'shar: over-writing existing file hanoi.c'
  617. fi
  618. sed 's/^X//' > hanoi.c <<'End-of-File-Grunt'
  619. X/*
  620. X *  $Header: hanoi.c,v 3.5 87/08/06 08:11:14 kenj Exp $
  621. X */
  622. X#define PRINT 0
  623. X#define DISK 3
  624. X#define other(i,j) (6-(i+j))
  625. Xint num[4];
  626. Xlong cnt;
  627. Xmain(argc,argv)
  628. Xchar **argv;
  629. X{
  630. X    int disk;
  631. X    disk  = DISK;
  632. X    if(argc > 1)disk = atoi(argv[1]);
  633. X    num[1] = disk;
  634. X    if(PRINT)printf("Start %d on A\n",disk);
  635. X    mov(disk,1,3);
  636. X    printf("For %d disks, %ld moves\n",disk,cnt);
  637. X
  638. X    exit(0);
  639. X}
  640. X
  641. Xmov(n,f,t)
  642. X{
  643. X    int o;
  644. X    if(n == 1) {
  645. X        num[f]--;
  646. X        num[t]++;
  647. X        if(PRINT)printf("Move from %d to %d, result: A:%d B:%d C%d\n",
  648. X            f,t,num[1],num[2],num[3]);
  649. X        cnt++;
  650. X        return;
  651. X    }
  652. X    o = other(f,t);
  653. X    mov(n-1,f,o);
  654. X    mov(1,f,t);
  655. X    mov(n-1,o,t);
  656. X    return;
  657. X}
  658. End-of-File-Grunt
  659. if test 619 -ne `cat 'hanoi.c' | wc -c`
  660. then
  661.     echo 'shar: transmission error (expected 619 characters)'
  662. fi
  663. echo 'x - iamalive.c'
  664. if test -f 'iamalive.c'
  665. then
  666.     echo 'shar: over-writing existing file iamalive.c'
  667. fi
  668. sed 's/^X//' > iamalive.c <<'End-of-File-Grunt'
  669. X/*
  670. X * echo argv[1] without \n, to tell user we are still alive
  671. X *
  672. X *  $Header: iamalive.c,v 3.4 87/06/22 14:23:22 kjmcdonell Beta $
  673. X */
  674. Xmain(argc, argv)
  675. Xint    argc;
  676. Xchar    *argv[];
  677. X{
  678. X    if (argc == 2)
  679. X        printf("%s ", argv[1]);
  680. X    exit(0);
  681. X}
  682. End-of-File-Grunt
  683. if test 233 -ne `cat 'iamalive.c' | wc -c`
  684. then
  685.     echo 'shar: transmission error (expected 233 characters)'
  686. fi
  687. echo 'x - keyb.c'
  688. if test -f 'keyb.c'
  689. then
  690.     echo 'shar: over-writing existing file keyb.c'
  691. fi
  692. sed 's/^X//' > keyb.c <<'End-of-File-Grunt'
  693. X/*
  694. X *  keyb -- emulate a user typing at a terminal
  695. X *
  696. X *  keyb [ datafile ]
  697. X *
  698. X *  standard input is copied to standard output at a rate not in excess
  699. X *  of "rate" characters per second, and copied to "copyfile" if
  700. X *  specified
  701. X *
  702. X *  environment variables $rate and $tty control typing rate (characters
  703. X *  per second) and destination of echoed output.
  704. X *
  705. X *  $Header: keyb.c,v 3.5 87/06/22 14:24:28 kjmcdonell Beta $
  706. X */
  707. X
  708. X#include <stdio.h>
  709. X#include <signal.h>
  710. X
  711. X#define DEF_RATE    5
  712. X#define GRANULE        5
  713. X
  714. Xint    thres;
  715. Xint    est_rate = DEF_RATE;
  716. Xint    sigpipe;    /* pipe write error flag */
  717. X
  718. Xmain(argc, argv)
  719. Xint    argc;
  720. Xchar    *argv[];
  721. X{
  722. X    int        i;
  723. X    int        l;
  724. X    int        fcopy = 0;    /* fd for copy output */
  725. X    int        output;        /* aggregate output char count */
  726. X    int        c;
  727. X    int        nch;        /* # characters read */
  728. X    char    buf[16];    /* the current glob of data */
  729. X    int        onalarm();
  730. X    int        pipeerr();
  731. X    char    *getenv();
  732. X    int        written;
  733. X    char    *p;
  734. X    char    *prog;        /* my name */
  735. X
  736. X    prog = argv[0];
  737. X    if ((p = getenv("rate")) != (char *)0) {
  738. X    sscanf(p, "%f", &est_rate);
  739. X    if (est_rate <= 0) {
  740. X        fprintf(stderr, "%s: bad rate, reset to %.2f chars/sec\n", prog, DEF_RATE);
  741. X        est_rate = DEF_RATE;
  742. X    }
  743. X#ifdef DEBUG
  744. X    else
  745. X        fprintf(stderr, "%s: typing rate %.2f chars/sec\n", est_rate);
  746. X#endif
  747. X    }
  748. X    if ((p = getenv("tty")) != (char *)0) {
  749. X    fcopy = open(p, 1);
  750. X    if (fcopy < 0)
  751. X        fcopy = creat(p, 0600);
  752. X    if (fcopy < 0) {
  753. X        fprintf(stderr, "%s: cannot open copy file '%s'\n", prog, p);
  754. X        exit(2);
  755. X    }
  756. X    lseek(fcopy, 0L, 2);    /* append at end of file */
  757. X    }
  758. X    
  759. X    if (argc == 2) {
  760. X    /* datafile argument specified */
  761. X    close(0);
  762. X    if (open(argv[1], 0) < 0) {
  763. X        fprintf(stderr, "%s: Cannot open %s\n", prog, argv[1]);
  764. X        exit(4);
  765. X    }
  766. X    }
  767. X
  768. X    srand(time(0));
  769. X    thres = est_rate = est_rate * GRANULE;
  770. X    output = 0;
  771. X
  772. X    signal(SIGPIPE, pipeerr);
  773. X    signal(SIGALRM, onalarm);
  774. X    alarm(GRANULE);
  775. X    while (1) {
  776. X    l = rand() % 15 + 1;    /* 1-15 chars */
  777. X    if (l == 0) continue;
  778. X    nch = read(0, buf, l);
  779. X    if (nch == 0)
  780. X        break;
  781. X    if ((written = write(1, buf, nch)) != nch) {
  782. X        /* argh! */
  783. X        if (sigpipe)
  784. X        fprintf(stderr, "type: ** SIGPIPE error ** buf: %s\n", buf);
  785. X        else
  786. X        fprintf(stderr, "type: ** write error ** buf: %s\n", buf);
  787. X        exit(4);
  788. X    }
  789. X    if (fcopy)
  790. X        write(fcopy, buf, nch);
  791. X    output += nch;
  792. X    while (output > thres)
  793. X        pause();
  794. X    }
  795. X    alarm(0);
  796. X    exit(0);
  797. X}
  798. X
  799. Xonalarm()
  800. X{
  801. X    thres += est_rate;
  802. X    signal(SIGALRM, onalarm);
  803. X    alarm(GRANULE);
  804. X}
  805. X
  806. Xpipeerr()
  807. X{
  808. X    sigpipe++;
  809. X}
  810. End-of-File-Grunt
  811. if test 2513 -ne `cat 'keyb.c' | wc -c`
  812. then
  813.     echo 'shar: transmission error (expected 2513 characters)'
  814. fi
  815. echo 'x - limit.c'
  816. if test -f 'limit.c'
  817. then
  818.     echo 'shar: over-writing existing file limit.c'
  819. fi
  820. sed 's/^X//' > limit.c <<'End-of-File-Grunt'
  821. X/*
  822. X *  Force a UNIX system to the per process and per user limits
  823. X *
  824. X *  $Header: limit.c,v 3.4 87/06/22 14:25:11 kjmcdonell Beta $
  825. X */
  826. X
  827. X#define    CLICK    1024
  828. X#define    MAXCHN    100
  829. X
  830. X#include <signal.h>
  831. X#include <setjmp.h>
  832. X
  833. Xint    parent;        /* parent's pid */
  834. Xint    child;        /* child's pid */
  835. Xint    pid[MAXCHN];
  836. Xint    ncall;
  837. Xint    level;
  838. Xjmp_buf    env;
  839. X
  840. Xmain(argc, argv)
  841. Xint    argc;
  842. Xchar    *argv[];
  843. X{
  844. X    char    *top;
  845. X    int    pad;
  846. X    int    end;
  847. X    int    i;
  848. X    int    status;
  849. X    float    f;
  850. X    int    flag();
  851. X    int    wakeup();
  852. X    long    last;
  853. X
  854. X    /* open files (file descriptors) */
  855. X    for (i = 3; open(".", 0) > 0; i++) ;
  856. X    printf("Maximum open files per process: %d\n", i);
  857. X    while (--i > 2)
  858. X        close(i);
  859. X
  860. X    /* process address space */
  861. X    top = (char *)sbrk(0);
  862. X#if debug
  863. X    printf("inital top of program: 0x%x\n", top);
  864. X#endif
  865. X    pad = (((int)top+CLICK-1)/CLICK)*CLICK - (int)top;
  866. X    sbrk(pad);
  867. X    for (i = 0; (char *)sbrk(CLICK) != (char *)-1; i++) ;
  868. X#if debug
  869. X    printf("final top of program: 0x%x\n", sbrk(0));
  870. X#endif
  871. X    brk(top);
  872. X#if debug
  873. X    printf("top of program restored to: 0x%x\n", sbrk(0));
  874. X#endif
  875. X    end = (((int)top+pad)/CLICK) + i;
  876. X    f = ((float)end * CLICK) / 1024;
  877. X    printf("Process address space limit: ");
  878. X    if (f < 1024)
  879. X        printf("%.2f Kbytes\n", f);
  880. X    else {
  881. X        f /= 1024;
  882. X        printf("%.2f Mbytes\n", f);
  883. X    }
  884. X
  885. X    /* process creations */
  886. X    printf("Maximum number of child processes:");
  887. X    i = 0;
  888. X    while (1) {
  889. X#if debug
  890. X        printf("about to fork\n");
  891. X#endif
  892. X        if ((pid[i] = fork()) == -1) {
  893. X#if debug
  894. X            perror("fork failed");
  895. X#endif
  896. X            break;
  897. X        } else if (pid[i] != 0) {
  898. X#if debug
  899. X            printf("child %d: pid=%d\n", i+1, pid[i]);
  900. X#endif
  901. X            i++;
  902. X            if (i >= MAXCHN) {
  903. X                printf(" more than");
  904. X                break;
  905. X            }
  906. X        } else {
  907. X#if debug
  908. X            printf("child %d pausing\n", getpid());
  909. X#endif
  910. X            pause();
  911. X#if debug
  912. X            printf("child %d exiting\n", getpid());
  913. X#endif
  914. X            exit(1);
  915. X        }
  916. X    }
  917. X    printf(" %d\n", i);
  918. X    while (--i >= 0) {
  919. X        kill(pid[i], SIGKILL);
  920. X        wait(0);
  921. X    }
  922. X
  923. X    ncall = level = 0;
  924. X    parent = getpid();
  925. X    signal(SIGTERM, flag);
  926. X    if ((child = fork()) == 0) {
  927. X        signal(SIGALRM, wakeup);
  928. X        recurse();
  929. X        exit(4);
  930. X    }
  931. X    while ((i = wait(&status)) == -1) {
  932. X    }
  933. X    printf("Estimated maximum stack size: %d Kbytes\n", level);
  934. X    exit(0);
  935. X}
  936. X
  937. Xrecurse()
  938. X{
  939. X    int    temp[1024 / sizeof(int)];
  940. X#if debug
  941. X    printf("recursion @ level %d\n", ncall);
  942. X#endif
  943. X    temp[1024 / sizeof(int) - 1] = 1;
  944. X    ncall++;
  945. X    kill(parent, SIGTERM);
  946. X    while (ncall > level) {
  947. X        alarm(2);
  948. X        pause();
  949. X    }
  950. X    if (ncall < 8000)
  951. X        /* less than 8M bytes of temp storage! */
  952. X        recurse();
  953. X    else
  954. X        /* give up! */
  955. X        exit(0);
  956. X}
  957. X
  958. Xflag()
  959. X{
  960. X    signal(SIGTERM, flag);
  961. X    level++;
  962. X    if (child != 0)
  963. X        kill(child, SIGTERM);
  964. X}
  965. X
  966. Xwakeup()
  967. X{
  968. X    signal(SIGALRM, wakeup);
  969. X}
  970. End-of-File-Grunt
  971. if test 2588 -ne `cat 'limit.c' | wc -c`
  972. then
  973.     echo 'shar: transmission error (expected 2588 characters)'
  974. fi
  975. echo 'x - log.785'
  976. if test -f 'log.785'
  977. then
  978.     echo 'shar: over-writing existing file log.785'
  979. fi
  980. sed 's/^X//' > log.785 <<'End-of-File-Grunt'
  981. X
  982. XMC="VAX 11/785"
  983. XOPT="FPA"
  984. XMEM="8 Mbytes"
  985. XUNIX="BSD 4.3 "
  986. XDISKS="2 x RA81"
  987. X
  988. XStart Benchmark Run (MUSBUS Version 5.0.Beta)
  989. X  Mon Jun 22 17:37:44 EDT 1987 (long iterations 6 times)
  990. X  11 interactive users.
  991. X
  992. XArithmetic Test (type = arithoh): 1000 Iterations
  993. XElapsed Time: 0.35 seconds (variance 0.007)
  994. XCPU Time: 0.22 seconds [ 0.22u + 0.00s ] (variance 0.002)
  995. X
  996. XArithmetic Test (type = register): 1000 Iterations
  997. XElapsed Time: 1.47 seconds (variance 0.011) (Actual: 1.12 )
  998. XCPU Time: 1.12 seconds [ 1.12u + 0.00s ] (variance 0.002) (Actual: 0.90 )
  999. X
  1000. XArithmetic Test (type = short): 1000 Iterations
  1001. XElapsed Time: 1.98 seconds (variance 0.022) (Actual: 1.63 )
  1002. XCPU Time: 1.70 seconds [ 1.70u + 0.00s ] (variance -0.000) (Actual: 1.48 )
  1003. X
  1004. XArithmetic Test (type = int): 1000 Iterations
  1005. XElapsed Time: 1.50 seconds (variance 0.008) (Actual: 1.15 )
  1006. XCPU Time: 1.30 seconds [ 1.30u + 0.00s ] (variance -0.000) (Actual: 1.08 )
  1007. X
  1008. XArithmetic Test (type = long): 1000 Iterations
  1009. XElapsed Time: 1.78 seconds (variance 0.078) (Actual: 1.43 )
  1010. XCPU Time: 1.35 seconds [ 1.33u + 0.02s ] (variance 0.003) (Actual: 1.13 )
  1011. X
  1012. XArithmetic Test (type = float): 1000 Iterations
  1013. XElapsed Time: 2.98 seconds (variance 0.726) (Actual: 2.63 )
  1014. XCPU Time: 2.43 seconds [ 2.40u + 0.03s ] (variance 0.003) (Actual: 2.21 )
  1015. X
  1016. XArithmetic Test (type = double): 1000 Iterations
  1017. XElapsed Time: 3.70 seconds (variance 1.016) (Actual: 3.35 )
  1018. XCPU Time: 2.37 seconds [ 2.30u + 0.07s ] (variance 0.011) (Actual: 2.15 )
  1019. X
  1020. XArithmetic Test (sqrt(2) with dc to 99 decimal places)
  1021. XElapsed Time: 2.43 seconds (variance 1.051)
  1022. XCPU Time: 1.45 seconds [ 1.33u + 0.12s ] (variance 0.007)
  1023. X
  1024. XRecursion Test: Tower of Hanoi Problem
  1025. X
  1026. X17 Disk Problem:
  1027. XElapsed Time: 5.42 seconds (variance 2.230)
  1028. XCPU Time: 4.30 seconds [ 4.20u + 0.10s ] (variance 0.008)
  1029. X
  1030. XSystem Call Overhead Test: 5 x 4000 Calls
  1031. XElapsed Time: 3.97 seconds (variance 0.243)
  1032. XCPU Time: 3.23 seconds [ 0.35u + 2.88s ] (variance 0.007)
  1033. X
  1034. XPipe Throughput Test: read & write 2048 x 512 byte blocks
  1035. XElapsed Time: 3.60 seconds (variance 0.020)
  1036. XCPU Time: 3.08 seconds [ 0.03u + 3.05s ] (variance 0.006)
  1037. X
  1038. XPipe-based Context Switching Test: 2 x 500 Switches
  1039. XElapsed Time: 1.57 seconds (variance 0.015)
  1040. XCPU Time: 0.70 seconds [ 0.05u + 0.65s ] (variance -0.000)
  1041. X
  1042. XProcess Creation Test: 100 forks
  1043. XElapsed Time: 1.93 seconds (variance 0.387)
  1044. XCPU Time: 1.45 seconds [ 0.00u + 1.45s ] (variance 0.003)
  1045. X
  1046. XExecl Throughput Test: 100 execs
  1047. XElapsed Time: 5.90 seconds (variance 28.036)
  1048. XCPU Time: 2.35 seconds [ 0.00u + 2.35s ] (variance 0.007)
  1049. X
  1050. XC Compiler Test:
  1051. X
  1052. Xcc -c cctest.c
  1053. XElapsed Time: 4.10 seconds (variance 0.130)
  1054. XCPU Time: 2.53 seconds [ 1.73u + 0.80s ] (variance 0.003)
  1055. X
  1056. Xcc cctest.o
  1057. XElapsed Time: 1.73 seconds (variance 0.303)
  1058. XCPU Time: 0.70 seconds [ 0.20u + 0.50s ] (variance 0.010)
  1059. X
  1060. XSequential Memory Access Test: 100000 Accesses
  1061. X
  1062. XArray Size: 8 Kbytes
  1063. X** Iteration  2  real loop < ohead:  100000 -478 0.017
  1064. XElapsed Time: 0.16 seconds (variance 0.015)
  1065. XCPU Time: 0.11 seconds (variance 0.003)
  1066. XReal Rate: 613497 int array accesses / second
  1067. X
  1068. XArray Size: 64 Kbytes
  1069. XElapsed Time: 0.19 seconds (variance 0.005)
  1070. XCPU Time: 0.17 seconds (variance 0.001)
  1071. XReal Rate: 528634 int array accesses / second
  1072. X
  1073. XArray Size: 512 Kbytes
  1074. X** Iteration  4  real loop < ohead:  100000 -461 0.200
  1075. XElapsed Time: 0.36 seconds (variance 0.051)
  1076. XCPU Time: 0.29 seconds (variance 0.002)
  1077. XReal Rate: 278552 int array accesses / second
  1078. X
  1079. XRandom Memory Access Test: 100000 Accesses
  1080. X
  1081. XArray Size: 8 Kbytes
  1082. XElapsed Time: 0.15 seconds (variance 0.001)
  1083. XCPU Time: 0.15 seconds (variance 0.001)
  1084. XReal Rate: 667408 int array accesses / second
  1085. X
  1086. XArray Size: 64 Kbytes
  1087. XElapsed Time: 0.18 seconds (variance 0.003)
  1088. XCPU Time: 0.18 seconds (variance 0.000)
  1089. XReal Rate: 555042 int array accesses / second
  1090. X
  1091. XArray Size: 512 Kbytes
  1092. XElapsed Time: 0.32 seconds (variance 0.001)
  1093. XCPU Time: 0.33 seconds (variance 0.000)
  1094. XReal Rate: 309917 int array accesses / second
  1095. X
  1096. XFilesystem Throughput Test:
  1097. X
  1098. XFile Size: 62 blocks
  1099. XWrite: 221.4 Kbytes per second   (variance 2919.0)
  1100. XRead:  181.6 Kbytes per second   (variance 1253.2)
  1101. XCopy:  62.4 Kbytes per second   (variance 130.2)
  1102. X
  1103. XFile Size: 125 blocks
  1104. XWrite: 252.0 Kbytes per second   (variance 919.1)
  1105. XRead:  151.9 Kbytes per second   (variance 230.7)
  1106. XCopy:  80.9 Kbytes per second   (variance 66.2)
  1107. X
  1108. XFile Size: 250 blocks
  1109. XWrite: 300.1 Kbytes per second   (variance 2511.2)
  1110. XRead:  170.1 Kbytes per second   (variance 173.9)
  1111. XCopy:  71.1 Kbytes per second   (variance 44.4)
  1112. X
  1113. XFile Size: 500 blocks
  1114. XWrite: 338.7 Kbytes per second   (variance 375.2)
  1115. XRead:  178.2 Kbytes per second   (variance 541.2)
  1116. XCopy:  86.1 Kbytes per second   (variance 43.5)
  1117. X
  1118. X
  1119. XOutput sent to ... /dev/ttyh0
  1120. XDirectories for temporary files ... Tmp
  1121. X
  1122. XFilesystem    kbytes    used   avail capacity  Mounted on
  1123. X/dev/ra0a       7429    4997    1689    75%    /
  1124. X/dev/ra0g      38879     672   34319     2%    /tmp
  1125. X/dev/ra0h     361860  286238   39436    88%    /usr
  1126. X/dev/ra1g      38879   33960    1031    97%    /backup
  1127. X/dev/ra1h     361860  273307   52367    84%    /u
  1128. X
  1129. XSIGALRM check:  12 x 5 sec delays takes 60.04 wallclock secs (error -0.06%)
  1130. XSimulated Multi-user Work Load Test:
  1131. X
  1132. X1 Concurrent Users, each with Input Keyboard Rate 2 chars / sec
  1133. XElapsed Time: 391.10 seconds (variance 0.656)
  1134. XCPU Time: 15.67 seconds [ 9.10u + 6.57s ] (variance 0.503)
  1135. X
  1136. X4 Concurrent Users, each with Input Keyboard Rate 2 chars / sec
  1137. XElapsed Time: 392.73 seconds (variance 0.281)
  1138. XCPU Time: 61.37 seconds [ 37.07u + 24.30s ] (variance 1.853)
  1139. X
  1140. X8 Concurrent Users, each with Input Keyboard Rate 2 chars / sec
  1141. XElapsed Time: 395.17 seconds (variance 3.797)
  1142. XCPU Time: 125.30 seconds [ 75.33u + 49.97s ] (variance 0.092)
  1143. X
  1144. X  15 interactive users.
  1145. XEnd Benchmark Run (Tue Jun 23 08:50:34 EDT 1987) ....
  1146. End-of-File-Grunt
  1147. if test 5694 -ne `cat 'log.785' | wc -c`
  1148. then
  1149.     echo 'shar: transmission error (expected 5694 characters)'
  1150. fi
  1151. echo 'x - log.sun3-50'
  1152. if test -f 'log.sun3-50'
  1153. then
  1154.     echo 'shar: over-writing existing file log.sun3-50'
  1155. fi
  1156. sed 's/^X//' > log.sun3-50 <<'End-of-File-Grunt'
  1157. X
  1158. XMC="Sun 3/50"
  1159. XOPT=""
  1160. XMEM="4 Mbytes"
  1161. XUNIX="Sun OS 3.2 +4.3BSD"
  1162. XDISKS="Sun 3/180 NFS server, 8 Mb, 2 Eagles, Zylogics controller"
  1163. X
  1164. XStart Benchmark Run (MUSBUS Version 5.0.Beta)
  1165. X  Wed Jun 24 14:55:15 EDT 1987 (long iterations 6 times)
  1166. X  1 interactive users.
  1167. X
  1168. XArithmetic Test (type = arithoh): 1000 Iterations
  1169. XElapsed Time: 0.32 seconds (variance 0.002)
  1170. XCPU Time: 0.22 seconds [ 0.20u + 0.02s ] (variance 0.002)
  1171. X
  1172. XArithmetic Test (type = register): 1000 Iterations
  1173. XElapsed Time: 1.32 seconds (variance 0.002)
  1174. XCPU Time: 1.22 seconds [ 1.20u + 0.02s ] (variance 0.002)
  1175. X
  1176. XArithmetic Test (type = short): 1000 Iterations
  1177. XElapsed Time: 1.55 seconds (variance 0.007)
  1178. XCPU Time: 1.42 seconds [ 1.40u + 0.02s ] (variance 0.002)
  1179. X
  1180. XArithmetic Test (type = int): 1000 Iterations
  1181. XElapsed Time: 1.62 seconds (variance 0.010)
  1182. XCPU Time: 1.52 seconds [ 1.50u + 0.02s ] (variance 0.002)
  1183. X
  1184. XArithmetic Test (type = long): 1000 Iterations
  1185. XElapsed Time: 1.58 seconds (variance 0.006)
  1186. XCPU Time: 1.48 seconds [ 1.47u + 0.02s ] (variance 0.002)
  1187. X
  1188. XArithmetic Test (type = float): 1000 Iterations
  1189. XElapsed Time: 41.70 seconds (variance 0.560)
  1190. XCPU Time: 40.98 seconds [ 40.78u + 0.20s ] (variance 0.026)
  1191. X
  1192. XArithmetic Test (type = double): 1000 Iterations
  1193. XElapsed Time: 37.03 seconds (variance 0.023)
  1194. XCPU Time: 36.72 seconds [ 36.57u + 0.15s ] (variance 0.006)
  1195. X
  1196. XArithmetic Test (sqrt(2) with dc to 99 decimal places)
  1197. XElapsed Time: 1.65 seconds (variance 0.007)
  1198. XCPU Time: 1.50 seconds [ 1.37u + 0.13s ] (variance 0.000)
  1199. X
  1200. XRecursion Test: Tower of Hanoi Problem
  1201. X
  1202. X17 Disk Problem:
  1203. XElapsed Time: 2.13 seconds (variance 0.003)
  1204. XCPU Time: 2.03 seconds [ 2.00u + 0.03s ] (variance 0.003)
  1205. X
  1206. XSystem Call Overhead Test: 5 x 4000 Calls
  1207. XElapsed Time: 3.65 seconds (variance 0.007)
  1208. XCPU Time: 3.53 seconds [ 0.53u + 3.00s ] (variance 0.007)
  1209. X
  1210. XPipe Throughput Test: read & write 2048 x 512 byte blocks
  1211. XElapsed Time: 6.02 seconds (variance 0.014)
  1212. XCPU Time: 5.88 seconds [ 0.10u + 5.78s ] (variance 0.002)
  1213. X
  1214. XPipe-based Context Switching Test: 2 x 500 Switches
  1215. XElapsed Time: 1.63 seconds (variance 0.007)
  1216. XCPU Time: 0.80 seconds [ 0.00u + 0.80s ] (variance 0.012)
  1217. X
  1218. XProcess Creation Test: 100 forks
  1219. XElapsed Time: 2.65 seconds (variance 0.015)
  1220. XCPU Time: 2.50 seconds [ 0.02u + 2.48s ] (variance 0.000)
  1221. X
  1222. XExecl Throughput Test: 100 execs
  1223. XElapsed Time: 6.93 seconds (variance 0.019)
  1224. XCPU Time: 6.07 seconds [ 0.00u + 6.07s ] (variance 0.007)
  1225. X
  1226. XC Compiler Test:
  1227. X
  1228. Xcc -c cctest.c
  1229. XElapsed Time: 7.13 seconds (variance 0.103)
  1230. XCPU Time: 3.13 seconds [ 1.97u + 1.17s ] (variance 0.003)
  1231. X
  1232. Xcc cctest.o
  1233. XElapsed Time: 3.53 seconds (variance 0.103)
  1234. XCPU Time: 0.80 seconds [ 0.33u + 0.47s ] (variance 0.030)
  1235. X
  1236. XSequential Memory Access Test: 100000 Accesses
  1237. X
  1238. XArray Size: 8 Kbytes
  1239. XElapsed Time: 0.12 seconds (variance 0.000)
  1240. XCPU Time: 0.14 seconds (variance 0.000)
  1241. XReal Rate: 810811 int array accesses / second
  1242. X
  1243. XArray Size: 64 Kbytes
  1244. X** Iteration  6  real loop < ohead:  100000 -500 0.167
  1245. XElapsed Time: 0.32 seconds (variance 0.104)
  1246. XCPU Time: 0.15 seconds (variance 0.001)
  1247. XReal Rate: 309438 int array accesses / second
  1248. X
  1249. XArray Size: 512 Kbytes
  1250. XElapsed Time: 0.17 seconds (variance 0.002)
  1251. XCPU Time: 0.18 seconds (variance 0.001)
  1252. XReal Rate: 588235 int array accesses / second
  1253. X
  1254. XRandom Memory Access Test: 100000 Accesses
  1255. X
  1256. XArray Size: 8 Kbytes
  1257. XElapsed Time: 0.22 seconds (variance 0.000)
  1258. XCPU Time: 0.22 seconds (variance 0.000)
  1259. XReal Rate: 448430 int array accesses / second
  1260. X
  1261. XArray Size: 64 Kbytes
  1262. XElapsed Time: 0.28 seconds (variance 0.009)
  1263. XCPU Time: 0.25 seconds (variance 0.001)
  1264. XReal Rate: 357782 int array accesses / second
  1265. X
  1266. XArray Size: 512 Kbytes
  1267. XElapsed Time: 0.32 seconds (variance 0.021)
  1268. XCPU Time: 0.27 seconds (variance 0.005)
  1269. XReal Rate: 316289 int array accesses / second
  1270. X
  1271. XFilesystem Throughput Test:
  1272. X
  1273. XFile Size: 62 blocks
  1274. XWrite: 69.3 Kbytes per second   (variance 383.2)
  1275. XRead:  227.1 Kbytes per second   (variance 96.7)
  1276. XCopy:  76.3 Kbytes per second   (variance 8.4)
  1277. X
  1278. XFile Size: 125 blocks
  1279. XWrite: 66.8 Kbytes per second   (variance 6.3)
  1280. XRead:  237.4 Kbytes per second   (variance 26.4)
  1281. XCopy:  61.6 Kbytes per second   (variance 13.1)
  1282. X
  1283. XFile Size: 250 blocks
  1284. XWrite: 59.4 Kbytes per second   (variance 3.8)
  1285. XRead:  238.9 Kbytes per second   (variance 6.8)
  1286. XCopy:  52.4 Kbytes per second   (variance 5.7)
  1287. X
  1288. XFile Size: 500 blocks
  1289. XWrite: 45.5 Kbytes per second   (variance 14.0)
  1290. XRead:  243.5 Kbytes per second   (variance 1.9)
  1291. XCopy:  28.8 Kbytes per second   (variance 74.5)
  1292. X
  1293. X
  1294. XOutput sent to ... /dev/console
  1295. XDirectories for temporary files ... Tmp
  1296. X
  1297. XFilesystem            kbytes    used   avail capacity  Mounted on
  1298. X/dev/nd0                3859    2795     678    80%    /
  1299. X/dev/ndp1               8639    3856    3919    50%    /pub
  1300. Xlily-lilynet:/          7735    4764    2197    68%    /server_root
  1301. Xlily-lilynet:/u       278443  188883   61715    75%    /u
  1302. Xlily-lilynet:/usr     161167  142089    2961    98%    /usr
  1303. Xlily-lilynet:/usr/private/lily13
  1304. X                      161167  142089    2961    98%    /private_nfs
  1305. X
  1306. XSIGALRM check:  12 x 5 sec delays takes 60.00 wallclock secs (error 0.00%)
  1307. XSimulated Multi-user Work Load Test:
  1308. X
  1309. X1 Concurrent Users, each with Input Keyboard Rate 2 chars / sec
  1310. XElapsed Time: 359.70 seconds (variance 29.656)
  1311. XCPU Time: 20.17 seconds [ 8.33u + 11.83s ] (variance 0.163)
  1312. X
  1313. X4 Concurrent Users, each with Input Keyboard Rate 2 chars / sec
  1314. XElapsed Time: 361.23 seconds (variance 18.906)
  1315. XCPU Time: 89.73 seconds [ 34.37u + 55.37s ] (variance 1.201)
  1316. X
  1317. X8 Concurrent Users, each with Input Keyboard Rate 2 chars / sec
  1318. XElapsed Time: 374.20 seconds (variance 348.797)
  1319. XCPU Time: 189.17 seconds [ 69.17u + 120.00s ] (variance 1.023)
  1320. X
  1321. X  1 interactive users.
  1322. XEnd Benchmark Run (Wed Jun 24 14:55:15 EDT 1987) ....
  1323. End-of-File-Grunt
  1324. if test 5641 -ne `cat 'log.sun3-50' | wc -c`
  1325. then
  1326.     echo 'shar: transmission error (expected 5641 characters)'
  1327. fi
  1328. echo 'x - log.uVaxII'
  1329. if test -f 'log.uVaxII'
  1330. then
  1331.     echo 'shar: over-writing existing file log.uVaxII'
  1332. fi
  1333. sed 's/^X//' > log.uVaxII <<'End-of-File-Grunt'
  1334. X
  1335. XMC="uVaxII (VaxStation II/GPX)"
  1336. XOPT="FP unit"
  1337. XMEM="3 Mbytes"
  1338. XUNIX="Ultrix 1.2"
  1339. XDISKS="RD53"
  1340. X
  1341. XStart Benchmark Run (MUSBUS Version 5.0.Beta)
  1342. X  Tue Jun 23 17:18:21 EDT 1987 (long iterations 6 times)
  1343. X  2 interactive users.
  1344. X
  1345. XArithmetic Test (type = arithoh): 1000 Iterations
  1346. XElapsed Time: 0.52 seconds (variance 0.002)
  1347. XCPU Time: 0.37 seconds [ 0.37u + 0.00s ] (variance 0.003)
  1348. X
  1349. XArithmetic Test (type = register): 1000 Iterations
  1350. XElapsed Time: 2.15 seconds (variance 0.051) (Actual: 1.63 )
  1351. XCPU Time: 1.92 seconds [ 1.90u + 0.02s ] (variance 0.002) (Actual: 1.55 )
  1352. X
  1353. XArithmetic Test (type = short): 1000 Iterations
  1354. XElapsed Time: 3.12 seconds (variance 0.114) (Actual: 2.60 )
  1355. XCPU Time: 2.83 seconds [ 2.80u + 0.03s ] (variance 0.003) (Actual: 2.46 )
  1356. X
  1357. XArithmetic Test (type = int): 1000 Iterations
  1358. XElapsed Time: 2.45 seconds (variance 0.003) (Actual: 1.93 )
  1359. XCPU Time: 2.30 seconds [ 2.30u + 0.00s ] (variance 0.000) (Actual: 1.93 )
  1360. X
  1361. XArithmetic Test (type = long): 1000 Iterations
  1362. XElapsed Time: 2.48 seconds (variance 0.006) (Actual: 1.96 )
  1363. XCPU Time: 2.30 seconds [ 2.28u + 0.02s ] (variance 0.004) (Actual: 1.93 )
  1364. X
  1365. XArithmetic Test (type = float): 1000 Iterations
  1366. XElapsed Time: 5.13 seconds (variance 0.031) (Actual: 4.61 )
  1367. XCPU Time: 4.82 seconds [ 4.80u + 0.02s ] (variance 0.002) (Actual: 4.45 )
  1368. X
  1369. XArithmetic Test (type = double): 1000 Iterations
  1370. XElapsed Time: 3.97 seconds (variance 0.015) (Actual: 3.45 )
  1371. XCPU Time: 3.72 seconds [ 3.70u + 0.02s ] (variance 0.002) (Actual: 3.35 )
  1372. X
  1373. XArithmetic Test (sqrt(2) with dc to 99 decimal places)
  1374. XElapsed Time: 2.92 seconds (variance 0.086)
  1375. XCPU Time: 2.53 seconds [ 2.40u + 0.13s ] (variance 0.003)
  1376. X
  1377. XRecursion Test: Tower of Hanoi Problem
  1378. X
  1379. X17 Disk Problem:
  1380. XElapsed Time: 5.20 seconds (variance 0.008)
  1381. XCPU Time: 4.97 seconds [ 4.93u + 0.03s ] (variance 0.007)
  1382. X
  1383. XSystem Call Overhead Test: 5 x 4000 Calls
  1384. XElapsed Time: 5.55 seconds (variance 0.055)
  1385. XCPU Time: 5.28 seconds [ 0.75u + 4.53s ] (variance 0.002)
  1386. X
  1387. XPipe Throughput Test: read & write 2048 x 512 byte blocks
  1388. XElapsed Time: 4.12 seconds (variance 0.010)
  1389. XCPU Time: 3.92 seconds [ 0.12u + 3.80s ] (variance 0.002)
  1390. X
  1391. XPipe-based Context Switching Test: 2 x 500 Switches
  1392. XElapsed Time: 2.13 seconds (variance 0.031)
  1393. XCPU Time: 0.90 seconds [ 0.03u + 0.87s ] (variance 0.004)
  1394. X
  1395. XProcess Creation Test: 100 forks
  1396. XElapsed Time: 1.98 seconds (variance 0.162)
  1397. XCPU Time: 1.63 seconds [ 0.00u + 1.63s ] (variance 0.003)
  1398. X
  1399. XExecl Throughput Test: 100 execs
  1400. XElapsed Time: 5.80 seconds (variance 0.716)
  1401. XCPU Time: 3.02 seconds [ 0.10u + 2.92s ] (variance 0.010)
  1402. X
  1403. XC Compiler Test:
  1404. X
  1405. Xcc -c cctest.c
  1406. XElapsed Time: 5.50 seconds (variance 0.130)
  1407. XCPU Time: 3.83 seconds [ 2.87u + 0.97s ] (variance 0.013)
  1408. X
  1409. Xcc cctest.o
  1410. XElapsed Time: 3.27 seconds (variance 0.103)
  1411. XCPU Time: 0.77 seconds [ 0.30u + 0.47s ] (variance 0.003)
  1412. X
  1413. XSequential Memory Access Test: 100000 Accesses
  1414. X
  1415. XArray Size: 8 Kbytes
  1416. XElapsed Time: 0.20 seconds (variance 0.005)
  1417. XCPU Time: 0.21 seconds (variance 0.001)
  1418. XReal Rate: 508475 int array accesses / second
  1419. X
  1420. XArray Size: 64 Kbytes
  1421. XElapsed Time: 0.44 seconds (variance 0.113)
  1422. XCPU Time: 0.26 seconds (variance 0.001)
  1423. XReal Rate: 227273 int array accesses / second
  1424. X
  1425. XArray Size: 512 Kbytes
  1426. XElapsed Time: 0.38 seconds (variance 0.001)
  1427. XCPU Time: 0.38 seconds (variance 0.001)
  1428. XReal Rate: 262009 int array accesses / second
  1429. X
  1430. XRandom Memory Access Test: 100000 Accesses
  1431. X
  1432. XArray Size: 8 Kbytes
  1433. XElapsed Time: 0.16 seconds (variance 0.000)
  1434. XCPU Time: 0.17 seconds (variance 0.000)
  1435. XReal Rate: 631579 int array accesses / second
  1436. X
  1437. XArray Size: 64 Kbytes
  1438. XElapsed Time: 0.33 seconds (variance 0.000)
  1439. XCPU Time: 0.33 seconds (variance 0.000)
  1440. XReal Rate: 301508 int array accesses / second
  1441. X
  1442. XArray Size: 512 Kbytes
  1443. XElapsed Time: 0.57 seconds (variance 0.004)
  1444. XCPU Time: 0.55 seconds (variance 0.001)
  1445. XReal Rate: 175953 int array accesses / second
  1446. X
  1447. XFilesystem Throughput Test:
  1448. X
  1449. XFile Size: 62 blocks
  1450. XWrite: 86.7 Kbytes per second   (variance 1049.1)
  1451. XRead:  78.4 Kbytes per second   (variance 421.1)
  1452. XCopy:  38.1 Kbytes per second   (variance 34.4)
  1453. X
  1454. XFile Size: 125 blocks
  1455. XWrite: 116.2 Kbytes per second   (variance 3099.1)
  1456. XRead:  82.6 Kbytes per second   (variance 2.8)
  1457. XCopy:  42.2 Kbytes per second   (variance 19.6)
  1458. X
  1459. XFile Size: 250 blocks
  1460. XWrite: 193.0 Kbytes per second   (variance 1404.6)
  1461. XRead:  91.8 Kbytes per second   (variance 14.9)
  1462. XCopy:  46.1 Kbytes per second   (variance 5.4)
  1463. X
  1464. XFile Size: 500 blocks
  1465. XWrite: 99.0 Kbytes per second   (variance 89.5)
  1466. XRead:  97.5 Kbytes per second   (variance 20.6)
  1467. XCopy:  47.3 Kbytes per second   (variance 1.6)
  1468. X
  1469. XOutput sent to ... /dev/ttyp0
  1470. XDirectories for temporary files ... Tmp
  1471. X
  1472. XFilesystem    total    kbytes  kbytes  percent
  1473. X   node       kbytes    used    free   used    Mounted on
  1474. X/dev/ra0a       7447    4721    1981    70%    /
  1475. X/dev/ra0g      42003   30222    7580    80%    /usr
  1476. X
  1477. XSIGALRM check:  12 x 5 sec delays takes 60.05 wallclock secs (error -0.08%)
  1478. XSimulated Multi-user Work Load Test:
  1479. X
  1480. X1 Concurrent Users, each with Input Keyboard Rate 2 chars / sec
  1481. XElapsed Time: 355.97 seconds (variance 0.953)
  1482. XCPU Time: 22.20 seconds [ 15.23u + 6.97s ] (variance 0.010)
  1483. X
  1484. X4 Concurrent Users, each with Input Keyboard Rate 2 chars / sec
  1485. XElapsed Time: 359.60 seconds (variance 6.688)
  1486. XCPU Time: 88.80 seconds [ 61.20u + 27.60s ] (variance 0.026)
  1487. X
  1488. X8 Concurrent Users, each with Input Keyboard Rate 2 chars / sec
  1489. XElapsed Time: 380.70 seconds (variance 90.094)
  1490. XCPU Time: 178.37 seconds [ 123.30u + 55.07s ] (variance 0.652)
  1491. X
  1492. X  1 interactive users.
  1493. XEnd Benchmark Run (Wed Jun 24 09:33:55 EDT 1987) ....
  1494. End-of-File-Grunt
  1495. if test 5474 -ne `cat 'log.uVaxII' | wc -c`
  1496. then
  1497.     echo 'shar: transmission error (expected 5474 characters)'
  1498. fi
  1499. echo 'x - makework.c'
  1500. if test -f 'makework.c'
  1501. then
  1502.     echo 'shar: over-writing existing file makework.c'
  1503. fi
  1504. sed 's/^X//' > makework.c <<'End-of-File-Grunt'
  1505. X/*
  1506. X *  makework  -- emulate a series of terminal users
  1507. X *
  1508. X *  makework nusers
  1509. X *
  1510. X *  job streams are specified on standard input with lines of the form
  1511. X *  home_dir cmd_path_name [ options ] [ <stdin_file ] [ >stdout_file ]
  1512. X *
  1513. X *  Input is send to all nuser instances of the commands in the
  1514. X *  job streams at a rate not in excess of "rate" characters per second
  1515. X *  per command
  1516. X *
  1517. X *  environment variables $rate and $tty control typing rate (characters
  1518. X *  per second) and destination of echoed output.
  1519. X *
  1520. X *  $Header: makework.c,v 3.9 87/09/17 05:55:13 kenj Exp $
  1521. X */
  1522. X
  1523. X#include "makework.h"
  1524. X
  1525. X#define DEF_RATE    5.0
  1526. X#define GRANULE        5
  1527. X#define CHUNK        60
  1528. X
  1529. Xfloat    thres;
  1530. Xfloat    est_rate = DEF_RATE;
  1531. Xint    firstuser;    /* ordinal identification of first user for this
  1532. X             * process */
  1533. Xint    exit_status = 0;
  1534. Xint    sigpipe;    /* pipe write error flag */
  1535. Xint    nstream;
  1536. X
  1537. Xstatic stream *cp;
  1538. X
  1539. Xmain(argc, argv)
  1540. Xint    argc;
  1541. Xchar    *argv[];
  1542. X{
  1543. X    int        i;
  1544. X    int        l;
  1545. X    int        fcopy = 0;    /* fd for copy output */
  1546. X    int        master = 1;    /* the REAL master, == 0 for clones */
  1547. X    int        cmseq = 0;    /* clone/master seq number */
  1548. X    int        done;        /* count of children finished */
  1549. X    int        output;        /* aggregate output char count for all
  1550. X                   children */
  1551. X    int        c;
  1552. X    int        nch;        /* # characters to write */
  1553. X    int        written;    /* # characters actully written */
  1554. X    char    logname[20];    /* name of the log file(s) */
  1555. X    int        nusers;
  1556. X    int        onalarm();
  1557. X    int        pipeerr();
  1558. X    int        wrapup();
  1559. X    int        grunt();
  1560. X    int        pvec[2];    /* for pipes */
  1561. X    char    *p;
  1562. X    char    *prog;        /* my name */
  1563. X    char    *getenv();
  1564. X
  1565. X#ifndef DEBUG
  1566. X    freopen("Tmp/masterlog.00", "a", stderr);
  1567. X#endif
  1568. X    fprintf(stderr, "*** New Run ***  ");
  1569. X    prog = argv[0];
  1570. X    if ((p = getenv("rate")) != (char *)0) {
  1571. X    sscanf(p, "%f", &est_rate);
  1572. X    if (est_rate <= 0) {
  1573. X        fprintf(stderr, "%s: bad rate, reset to %.2f chars/sec\n", prog, DEF_RATE);
  1574. X        est_rate = DEF_RATE;
  1575. X    }
  1576. X#ifdef DEBUG
  1577. X    else
  1578. X        fprintf(stderr, "%s: typing rate reset to %.2f chars/sec\n", prog, est_rate);
  1579. X#endif
  1580. X    }
  1581. X    if ((p = getenv("tty")) != (char *)0) {
  1582. X    fcopy = open(p, 1);
  1583. X    if (fcopy < 0)
  1584. X        fcopy = creat(p, 0600);
  1585. X    if (fcopy < 0) {
  1586. X        fprintf(stderr, "%s: cannot open copy file '%s'\n", prog, p);
  1587. X        fflush(stderr);
  1588. X        exit(2);
  1589. X    }
  1590. X    lseek(fcopy, 0L, 2);    /* append at end of file */
  1591. X    }
  1592. X    
  1593. X    if (argc < 2) {
  1594. X    fprintf(stderr, "%s: missing nusers\n", prog);
  1595. X    fflush(stderr);
  1596. X    exit(4);
  1597. X    }
  1598. X
  1599. X    nusers = atoi(argv[1]);
  1600. X    if (nusers < 1) {
  1601. X    fprintf(stderr, "%s: impossible nusers (%d<-%s)\n", prog, nusers, argv[1]);
  1602. X    fflush(stderr);
  1603. X    exit(4);
  1604. X    }
  1605. X    fprintf(stderr, "%d Users\n", nusers);
  1606. X    argc--;
  1607. X    argv++;
  1608. X
  1609. X    /* clone copies of myself to run up to MAXSTREAM jobs each */
  1610. X    firstuser = MAXSTREAM;
  1611. X    fprintf(stderr, "master pid %d\n", getpid());
  1612. X    fflush(stderr);
  1613. X    while (nusers > MAXSTREAM) {
  1614. X    fflush(stderr);
  1615. X    if (nusers >= 2*MAXSTREAM)
  1616. X        /* the next clone must run MAXSTREAM jobs */
  1617. X        nstream = MAXSTREAM;
  1618. X    else
  1619. X        /* the next clone must run the leftover jobs */
  1620. X        nstream = nusers - MAXSTREAM;
  1621. X    /* build job streams for the clone */
  1622. X    getwork(nstream);
  1623. X#ifdef DEBUG
  1624. X    dumpwork();
  1625. X#endif
  1626. X    cmseq = firstuser/MAXSTREAM;
  1627. X    if ((l = fork()) == -1) {
  1628. X        /* fork failed */
  1629. X        fatal("** clone fork failed **\n");
  1630. X        goto bepatient;
  1631. X    } else if (l > 0) {
  1632. X        fprintf(stderr, "clone %d pid %d\n", cmseq, l);
  1633. X        /* I am the master with nstream fewer jobs to run */
  1634. X        nusers -= nstream;
  1635. X        firstuser += MAXSTREAM;
  1636. X        continue;
  1637. X    } else {
  1638. X        /* I am a clone, run MAXSTREAM jobs */
  1639. X        master = 0;
  1640. X        nusers = nstream;
  1641. X#ifndef DEBUG
  1642. X        sprintf(logname, "Tmp/masterlog.%02d", cmseq);
  1643. X        freopen(logname, "w", stderr);
  1644. X#endif
  1645. X        break;
  1646. X    }
  1647. X    }
  1648. X    if (master) {
  1649. X    firstuser = 0;
  1650. X    cmseq = 0;
  1651. X    nstream = nusers;
  1652. X    /* build job streams for the master */
  1653. X    getwork(nstream);
  1654. X#ifdef DEBUG
  1655. X    dumpwork();
  1656. X#endif
  1657. X    }
  1658. X
  1659. X    close(0);
  1660. X
  1661. X    for (i = 0; i < nstream; i++ ) {
  1662. X    if (master)
  1663. X        fprintf(stderr, "user %d master stream %d ", firstuser+i, i);
  1664. X    else
  1665. X        fprintf(stderr, "user %d clone %d stream %d ", firstuser+i, cmseq, i);
  1666. X    if (pipe(pvec) == -1) {
  1667. X        /* this is fatal */
  1668. X        fatal("** pipe failed **\n");
  1669. X        goto bepatient;
  1670. X    }
  1671. X    fflush(stderr);
  1672. X    if ((work[i].pid = fork()) == 0) {
  1673. X        int    fd;
  1674. X        /* the command */
  1675. X        if (pvec[0] != 0) {
  1676. X        close(0);
  1677. X        dup(pvec[0]);
  1678. X        }
  1679. X#ifndef DEBUG
  1680. X        sprintf(logname, "Tmp/userlog.%02d", firstuser+i);
  1681. X        freopen(logname, "w", stderr);
  1682. X#endif
  1683. X        for (fd = 3; fd < 24; fd++)
  1684. X        close(fd);
  1685. X        if (work[i].tty[0] != '\0') {
  1686. X        /* redirect std output */
  1687. X        if (freopen(work[i].tty, "w", stdout) == NULL) {
  1688. X            fprintf(stderr, "makework: cannot open %s for std output\n",
  1689. X            work[i].tty);
  1690. X            fflush(stderr);
  1691. X            goto bepatient;
  1692. X        }
  1693. X        }
  1694. X        if (chdir(work[i].home) == -1) {
  1695. X        fprintf(stderr, "makework: chdir to \"%s\" failed!\n",
  1696. X            work[i].home);
  1697. X        fflush(stderr);
  1698. X        goto bepatient;
  1699. X        }
  1700. X        sprintf(logname, "USER.%02d", firstuser+i);
  1701. X        if (close(creat(logname, 0600)) == -1) {
  1702. X        fprintf(stderr, "makework: creat \"%s\" failed!\n", logname);
  1703. X        fflush(stderr);
  1704. X        goto bepatient;
  1705. X        }
  1706. X
  1707. X        execv(work[i].cmd, work[i].av);
  1708. X        /* don't expect to get here! */
  1709. X        fatal("** exec failed **\n");
  1710. X        goto bepatient;
  1711. X    }
  1712. X    else if (work[i].pid == -1) {
  1713. X        fatal("** fork failed **\n");
  1714. X        goto bepatient;
  1715. X    }
  1716. X    else {
  1717. X        close(pvec[0]);
  1718. X        work[i].fd = pvec[1];
  1719. X        work[i].line = work[i].bp = work[i].buf;
  1720. X        fprintf(stderr, "pid %d pipe fd %d", work[i].pid, work[i].fd);
  1721. X        if (work[i].tty[0] != '\0')
  1722. X        fprintf(stderr, " > %s", work[i].tty);
  1723. X        fputc('\n', stderr);
  1724. X    }
  1725. X    }
  1726. X    fflush(stderr);
  1727. X
  1728. X    srand(time(0));
  1729. X    thres = 0;
  1730. X    done = output = 0;
  1731. X    for (i = 0; i < nstream; i++) {
  1732. X    if (work[i].blen == 0)
  1733. X        done++;
  1734. X    else
  1735. X        thres += est_rate * GRANULE;
  1736. X    }
  1737. X    est_rate = thres;
  1738. X
  1739. X    signal(SIGALRM, onalarm);
  1740. X    signal(SIGPIPE, pipeerr);
  1741. X    alarm(GRANULE);
  1742. X    while (done < nstream) {
  1743. X    for (i = 0; i < nstream; i++) {
  1744. X        cp = &work[i];
  1745. X        if (cp->xmit >= cp->blen) continue;
  1746. X        l = rand() % CHUNK + 1;    /* 1-CHUNK chars */
  1747. X        if (l == 0) continue;
  1748. X        if (cp->xmit + l > cp->blen)
  1749. X        l = cp->blen - cp->xmit;
  1750. X        p = cp->bp;
  1751. X        cp->bp += l;
  1752. X        cp->xmit += l;
  1753. X#ifdef DEBUG
  1754. X        fprintf(stderr, "child %d, %d processed, %d to go\n", i, cp->xmit, cp->blen - cp->xmit);
  1755. X#endif
  1756. X        while (p < cp->bp) {
  1757. X        if (*p == '\n' || (p == &cp->bp[-1] && cp->xmit >= cp->blen)) {
  1758. X            /* write it out */
  1759. X            nch = p - cp->line + 1;
  1760. X            if ((written = write(cp->fd, cp->line, nch)) != nch) {
  1761. X            /* argh! */
  1762. X            cp->line[nch] = '\0';
  1763. X            fprintf(stderr, "user %d cmd %s ",
  1764. X                firstuser+i, cp->line);
  1765. X             fprintf(stderr, "write(,,%d) returns %d\n", nch, written);
  1766. X            if (sigpipe)
  1767. X                fatal("** SIGPIPE error **\n");
  1768. X            else
  1769. X                fatal("** write error **\n");
  1770. X            goto bepatient;
  1771. X
  1772. X            }
  1773. X            if (fcopy)
  1774. X            write(fcopy, cp->line, p - cp->line + 1);
  1775. X#ifdef DEBUG
  1776. X            fprintf(stderr, "child %d gets \"", i);
  1777. X            {
  1778. X            char *q = cp->line;
  1779. X            while (q <= p) {
  1780. X                if (*q >= ' ' && *q <= '~')
  1781. X                    fputc(*q, stderr);
  1782. X                else
  1783. X                    fprintf(stderr, "\\%03o", *q);
  1784. X                q++;
  1785. X            }
  1786. X            }
  1787. X            fputc('"', stderr);
  1788. X#endif
  1789. X            cp->line = &p[1];
  1790. X        }
  1791. X        p++;
  1792. X        }
  1793. X        if (cp->xmit >= cp->blen) {
  1794. X        done++;
  1795. X        close(cp->fd);
  1796. X#ifdef DEBUG
  1797. X    fprintf(stderr, "child %d, close std input\n", i);
  1798. X#endif
  1799. X        }
  1800. X        output += l;
  1801. X    }
  1802. X    while (output > thres) {
  1803. X        pause();
  1804. X#ifdef DEBUG
  1805. X        fprintf(stderr, "after pause: output, thres, done %d %.2f %d\n", output, thres, done);
  1806. X#endif
  1807. X    }
  1808. X    }
  1809. X
  1810. Xbepatient:
  1811. X    alarm(0);
  1812. X/****
  1813. X *  If everything is going OK, we should simply be able to keep
  1814. X *  looping unitil 'wait' fails, however some descendent process may
  1815. X *  be in a state from which it can never exit, and so a timeout
  1816. X *  is used.
  1817. X *  5 minutes should be ample, since the time to run all jobs is of
  1818. X *  the order of 5-10 minutes, however some machines are painfully slow,
  1819. X *  so the timeout has been set at 20 minutes (1200 seconds).
  1820. X ****/
  1821. X    signal(SIGALRM, grunt);
  1822. X    alarm(1200);
  1823. X    while ((c = wait(&l)) != -1) {
  1824. X        for (i = 0; i < nstream; i++) {
  1825. X        if (c == work[i].pid) {
  1826. X        fprintf(stderr, "user %d pid %d done", firstuser+i, c);
  1827. X        if (l != 0) {
  1828. X            if (l & 0x7f)
  1829. X            fprintf(stderr, " status %d", l & 0x7f);
  1830. X            if (l & 0xff00)
  1831. X            fprintf(stderr, " exit code %d", (l>>8) & 0xff);
  1832. X            exit_status = 4;
  1833. X        }
  1834. X        fputc('\n', stderr);
  1835. X        c = work[i].pid = -1;
  1836. X        break;
  1837. X        }
  1838. X    }
  1839. X    if (c != -1) {
  1840. X        fprintf(stderr, "clone %d done, pid %d ", cmseq, c);
  1841. X        if (l != 0) {
  1842. X        if (l & 0x7f)
  1843. X            fprintf(stderr, " status %d", l & 0x7f);
  1844. X        if (l & 0xff00)
  1845. X            fprintf(stderr, " exit code %d", (l>>8) & 0xff);
  1846. X        exit_status = 4;
  1847. X        }
  1848. X        fputc('\n', stderr);
  1849. X    }
  1850. X    }
  1851. X    alarm(0);
  1852. X    wrapup("Finished waiting ...");
  1853. X
  1854. X
  1855. X}
  1856. X
  1857. Xonalarm()
  1858. X{
  1859. X    thres += est_rate;
  1860. X    signal(SIGALRM, onalarm);
  1861. X    alarm(GRANULE);
  1862. X}
  1863. X
  1864. Xgrunt()
  1865. X{
  1866. X    /* timeout after label "bepatient" in main */
  1867. X    exit_status = 4;
  1868. X    wrapup("Timed out waiting for jobs to finish ...");
  1869. X}
  1870. X
  1871. Xpipeerr()
  1872. X{
  1873. X    sigpipe++;
  1874. X}
  1875. X
  1876. Xwrapup(reason)
  1877. Xchar    *reason;
  1878. X{
  1879. X    int i;
  1880. X    int killed = 0;
  1881. X    fflush(stderr);
  1882. X    for (i = 0; i < nstream; i++) {
  1883. X    if (work[i].pid > 0 && kill(work[i].pid, SIGKILL) != -1) {
  1884. X        if (!killed) {
  1885. X        killed++;
  1886. X        fprintf(stderr, "%s\n", reason);
  1887. X        fflush(stderr);
  1888. X        }
  1889. X        fprintf(stderr, "user %d pid %d killed off\n", firstuser+i, work[i].pid);
  1890. X    fflush(stderr);
  1891. X    }
  1892. X    }
  1893. X    exit(exit_status);
  1894. X}
  1895. End-of-File-Grunt
  1896. if test 9455 -ne `cat 'makework.c' | wc -c`
  1897. then
  1898.     echo 'shar: transmission error (expected 9455 characters)'
  1899. fi
  1900. echo 'x - makework.h'
  1901. if test -f 'makework.h'
  1902. then
  1903.     echo 'shar: over-writing existing file makework.h'
  1904. fi
  1905. sed 's/^X//' > makework.h <<'End-of-File-Grunt'
  1906. X#include <stdio.h>
  1907. X#include <signal.h>
  1908. X/* $Header: makework.h,v 1.4 87/06/24 08:33:56 kjmcdonell Beta $ */
  1909. X
  1910. X#define MAXSTREAM    12
  1911. X
  1912. Xtypedef struct st_stream {
  1913. X    char    *home;        /* home dir for job stream */
  1914. X    char    *cmd;        /* name of command to run */
  1915. X    char    **av;        /* arguments to command */
  1916. X    char    *buf;        /* standard input buffer */
  1917. X    int    blen;        /* size of standard input buffer */
  1918. X    int    xmit;        /* # characters sent */
  1919. X    char    *bp;        /* std input buffer pointer */
  1920. X    char    *tty;        /* standard output (filename) */
  1921. X    int    fd;        /* stdin to command */
  1922. X    int    pid;        /* PID of stream command */
  1923. X    char    *line;        /* start of input line */ 
  1924. X} stream;
  1925. X
  1926. Xextern stream work[];
  1927. X
  1928. Xextern int    nstream;    /* number of concurrent streams to be
  1929. X                 * simulated by this process */
  1930. Xextern int    exit_status;    /* returned to parent */
  1931. End-of-File-Grunt
  1932. if test 787 -ne `cat 'makework.h' | wc -c`
  1933. then
  1934.     echo 'shar: transmission error (expected 787 characters)'
  1935. fi
  1936. echo 'x - mem.awk'
  1937. if test -f 'mem.awk'
  1938. then
  1939.     echo 'shar: over-writing existing file mem.awk'
  1940. fi
  1941. sed 's/^X//' > mem.awk <<'End-of-File-Grunt'
  1942. X# $Header: mem.awk,v 3.4 87/06/22 14:27:39 kjmcdonell Beta $
  1943. X/real/    { next }
  1944. X/^[0-9][ .0-9-]*$/ && NF==3 { \
  1945. X    r=$2/1000; \
  1946. X    if (r < 0) { \
  1947. X        print "** Iteration ",iter+1," real loop < ohead: ",$0; \
  1948. X        r=0; \
  1949. X    } \
  1950. X    iter++; numacc=$1; real+=r; r2+=r*r; cpu+=$3; c2+=$3*$3; \
  1951. X    next; \
  1952. X    }
  1953. X{ print "** Iteration ",iter+1," Failed: ",$0 }
  1954. XEND {\
  1955. X    if (iter > 0) { \
  1956. X        printf "Elapsed Time: %.2f seconds",real/iter; \
  1957. X        if (iter > 1) printf " (variance %.3f)",(r2-2*real*real/iter+real*real/iter)/(iter-1); \
  1958. X        printf "\nCPU Time: %.2f seconds",cpu/iter; \
  1959. X        if (iter > 1) printf " (variance %.3f)",(c2-2*cpu*cpu/iter+cpu*cpu/iter)/(iter-1); \
  1960. X        print; \
  1961. X        printf "Real Rate: %.0f int array accesses / second\n",(numacc*iter)/real; \
  1962. X    } else { \
  1963. X        print "Elapsed Time: -- no measured results!!"; \
  1964. X        print "CPU Time: -- no measured results!!"; \
  1965. X    } \
  1966. X    }
  1967. End-of-File-Grunt
  1968. if test 882 -ne `cat 'mem.awk' | wc -c`
  1969. then
  1970.     echo 'shar: transmission error (expected 882 characters)'
  1971. fi
  1972.